<template>
	<view class="my-input" :style="{borderRadius:borderRadius+'px',borderColor:nowColor,height:height+'px',width:widthPercent+'%'}">
		<input :type="mode" :password="password" :placeholder="text" placeholder-class="input-text" @input="input"
		@focus="focus" @blur="blur"
		/>
	</view>
</template>

<script>
	export default {
		props: {
			borderRadius: {
				type: Number,
				default: 0
			},
			mode: {
				type: String,
				default () {
					return "text"
				}
			},
			password: {
				type: Boolean,
				default: false
			},
			text: {
				type: String,
			},
			borderColor: {
				type: String
			},
			height: {
				type: Number,
				default: 35
			},
			widthPercent: {
				type: Number,
				default: 50
			},
			needCheckColor: {
				type: Boolean,
				default: false
			},
			checkColor: {
				type: String,
				defalut(){
					return ""
				}
			}
		},
		data() {
			return{
				nowColor:""
			};
		},
		created() {
			this.nowColor = this.borderColor
		},
		methods: {
			input(v) {
				this.$emit("input",v.detail.value)
			},
			focus(){
				if(this.checkColor !== ""){
					this.nowColor = this.checkColor
				}
			},
			blur(){
				if(this.checkColor !== ""){
					this.nowColor = this.borderColor
				}
			}
		}
	}
</script>

<style>
	.my-input {
		border: 2rpx solid;
		padding: 0 20rpx;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
	}

	input {
		width: 100%;
	}

	.input-text {
		font-size: 28rpx;
	}
</style>
